﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using WcfContrib.Metadata;

namespace WcfContrib.Showcase.Client
{
    class Program
    {
        static void Main(string[] args)
        {
            Helpers.WriteLine(ConsoleColor.White, "Press any key to retrieve metadata..");
            Console.ReadKey();

            Helpers.WriteLine(ConsoleColor.Yellow, "Processing metadata address..");
            MetadataDescription metadata = MetadataHelper.GetMetadataDescription("http://localhost:1033/SampleServices/Service");
            
            Helpers.WriteLine(ConsoleColor.Cyan, "Done ({0} Endpoints), you can process the metadata and get all sort of information, including service defined policies!\r\n", metadata.Endpoints.Count);
            Helpers.WriteLine(ConsoleColor.Cyan, "Support for MEX / Http-Get");
            Helpers.WriteLine(ConsoleColor.Cyan, "Support net.pipe / net.tcp / http / https protocols and '?wsdl' automatic availability check");
            Helpers.WriteLine(ConsoleColor.Cyan, "You can use the helper to check if metadata is available");

            Helpers.WriteLine(ConsoleColor.White, "Press any key to exit..");
            Console.ReadKey();
        }
    }

    static class Helpers
    {
        internal static void WriteLine(ConsoleColor color, string input, params object[] format)
        {
            ConsoleColor orgColor = Console.ForegroundColor;

            Console.ForegroundColor = color;
            Console.WriteLine(string.Format(input, format));

            Console.ForegroundColor = orgColor;
        }
    }
}
